package com.zmn.oms.common.constant;

import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.zmn.common.constant.GlobalConsts;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

/**
 * @author ：SongWeidong
 * @date ：2020/1/14 10:51
 * @description：工单权限url配置常量类
 */
public class OrderPremissionConsts {

    /**
     * 超级管理员角色ID
     */
    public final static int SUPER_ADMIN_ROLE_ID = 101;


    // region 订单 module id
    /**
     * 啄木鸟 moduleId 510
     */
    public final static int MODULE_ID_ZS = 510;

    /**
     * 啄木鸟-会员工单 moduleId 520
     */
    public final static int MODULE_ID_ZS_MEMBER = 520;

    /**
     * 啄木鸟-财务工单 moduleId 530
     */
    public final static int MODULE_ID_ZS_BRANCHFINANCE = 530;

    /**
     * 啄木鸟-总财工单 moduleId 540
     */
    public final static int MODULE_ID_ZS_HQFINANCE = 540;

    /**
     * 啄木鸟-话务工单 moduleId 550
     */
    public final static int MODULE_ID_ZS_CUSTOMERSERVICE = 550;

    /**
     * 啄木鸟-品控工单 moduleId 560
     */
    public final static int MODULE_ID_ZS_QUALITYCONTROL = 560;

    /**
     * 啄木鸟-订单评价 moduleId 570
     */
    public final static int MODULE_ID_ZS_ORDER_COMMENT = 570;


    /**
     * 言而有信工单 moduleId 590
     */
    public final static int MODULE_ID_YEYX = 590;

    /**
     * 一步维修工单 moduleId 572
     */
    public final static int MODULE_ID_SAAS = 572;

    /**
     * 川南环保工单 moduleId 574
     */
    public final static int MODULE_ID_CNHB = 574;

    // endregion

    // region 权限基础路径
    /**
     * 啄木鸟 /zs
     */
    public final static String PATH_ZS = "/zs";

    /**
     * 言而有信 /yeyx
     */
    public final static String PATH_YEYX = "/ys";

    /**
     * 一步维修 /saas
     */
    public final static String PATH_SAAS = "/saas";

    /**
     * 川南环保 /cnhb
     */
    public final static String PATH_CNHB = "/cnhb";
    // endregion

    // region 订单详情权限

    // 敏感信息

    /**
     * 录单-录入测试单权限
     */
    public static final String ODP_TEST_ORDER = "/work/add/test.action";

    /**
     * 详情-用户地址信息
     */
    public static final String ODP_USER_ADDRESS = "/work/detail/useraddress.action";
    /**
     * 详情-用户电话
     */
    public static final String ODP_USER_PHONE = "/work/detail/userphone.action";
    /**
     * 详情-呼叫用户电话
     */
    public static final String ODP_CALL_PHONE = "/work/detail/call.action";
    /**
     * 详情-发短信
     */
    public static final String ODP_SEND_SMS = "/work/detail/sendsms.action";
    /**
     * 详情-师傅手机号
     */
    public static final String ODP_ENGINEER_PHONE = "/work/detail/masterphone.action";
    /**
     * 呼叫工程师 IM
     */
    public static final String ODP_ENGINEER_IMCALL = "/work/detail/engineer/imcall.action";
    /**
     * 详情-服务商电话
     */
    public static final String ODP_SERVICE_PHONE = "/work/detail/manage/company/service/phone.action";
    /**
     * 线索池-用户电话
     */
    public static final String CCD_USER_PHONE = "/chan/clueDetail/userPhone.action";
    /**
     * 线索池-用户地址
     */
    public static final String CCD_USER_ADDRESS = "/chan/clueDetail/userAddress.action";

    // 金额信息

    /**
     * 详情-工程师提留金额
     */
    public static final String ODP_COMMISSION_AMOUNT = "/work/detail/commission/amount.action";
    /**
     * 详情-工程师开票金额
     */
    public static final String ODP_BILL_AMOUNT = "/work/detail/bill/amount.action";
    /**
     * 详情-师傅提成金额
     */
    public static final String ODP_MASTER_REWARD = "/work/detail/master/reward.action";
    /**
     * 详情-订单金额内部价
     */
    public static final String ODP_PRICE_INTERNAL = "/work/detail/internal/settlement/amount.action";
    /**
     * 详情-订单金额
     */
    public static final String ODP_PRICE_EXTERNAL = "/work/detail/external/settlement/amount.action";
    /**
     * 详情-价格查询
     */
    public static final String ODP_PRICE_SELECT = "/work/price/order/detail.action";

    /**
     * 详情-日志查询权限
     */
    public static final String ODP_VIEW_ALL_LOG = "/work/detail/view/all/log.action";

    // regino 运杂费
    /**
     * 详情-运杂费配件总额
     */
    public static final String ODP_DELIVER_TOTAL_AMOUNT = "/work/detail/deliver/total_amount.action";
    /**
     * 详情-运杂费配件金额
     */
    public static final String ODP_DELIVER_AMOUNT = "/work/detail/deliver/amount.action";

    /**
     * 详情-内采配件成本总额
     */
    public static final String ODP_DELIVER_COST_TOTAL_AMOUNT = "/work/detail/deliver/cost/total_amount.action";
    /**
     * 详情-内采配件成本金额
     */
    public static final String ODP_DELIVER_COST_AMOUNT = "/work/detail/deliver/cost/amount.action";
    /**
     * 详情-内采配件销售总额
     */
    public static final String ODP_DELIVER_SALES_TOTAL_AMOUNT = "/work/detail/deliver/total_amount.action";
    /**
     * 详情-内采配件销售金额
     */
    public static final String ODP_DELIVER_SALES_AMOUNT = "/work/detail/deliver/amount.action";
    /**
     * 详情-内采配件采购总额
     */
    public static final String ODP_DELIVER_PURCHASE_TOTAL_AMOUNT = "/work/detail/deliver/purchase/total_amount.action";
    /**
     * 详情-内采配件采购金额
     */
    public static final String ODP_DELIVER_PURCHASE_AMOUNT = "/work/detail/deliver/purchase/amount.action";

    // endregion

    // region 内采
    /**
     * 详情-内采配件成本总额
     */
    public static final String ODP_IN_PART_COST_TOTAL_AMOUNT = "/work/detail/in/part/cost/total_amount.action";
    /**
     * 详情-内采配件成本金额
     */
    public static final String ODP_IN_PART_COST_AMOUNT = "/work/detail/in/part/cost/amount.action";
    /**
     * 详情-内采配件销售总额
     */
    public static final String ODP_IN_PART_SALES_TOTAL_AMOUNT = "/work/detail/in/part/total_amount.action";
    /**
     * 详情-内采配件销售金额
     */
    public static final String ODP_IN_PART_SALES_AMOUNT = "/work/detail/in/part/amount.action";
    /**
     * 详情-内采配件采购总额
     */
    public static final String ODP_IN_PART_PURCHASE_TOTAL_AMOUNT = "/work/detail/in/part/purchase/total_amount.action";
    /**
     * 详情-内采配件采购金额
     */
    public static final String ODP_IN_PART_PURCHASE_AMOUNT = "/work/detail/in/part/purchase/amount.action";


    // endregion

    // region 外报
    /**
     * 详情-外报配件成本总额
     */
    public static final String ODP_OUT_PART_COST_TOTAL_AMOUNT = "/work/detail/out/part/cost/total_amount.action";
    /**
     * 详情-外报配件成本金额
     */
    public static final String ODP_OUT_PART_COST_AMOUNT = "/work/detail/out/part/cost/amount.action";
    /**
     * 详情-外报配件销售总额
     */
    public static final String ODP_OUT_PART_SALES_TOTAL_AMOUNT = "/work/detail/out/part/total_amount.action";
    /**
     * 详情-外报配件销售金额
     */
    public static final String ODP_OUT_PART_SALES_AMOUNT = "/work/detail/out/part/amount.action";
    /**
     * 详情-外报配件采购总额
     */
    public static final String ODP_OUT_PART_PURCHASE_TOTAL_AMOUNT = "/work/detail/out/part/purchase/total_amount.action";
    /**
     * 详情-外报配件采购金额
     */
    public static final String ODP_OUT_PART_PURCHASE_AMOUNT = "/work/detail/out/part/purchase/amount.action";
    // endregion

    /**
     * 详情-垒多多分红
     */
    public static final String ODP_DMS_MASTER_BONUS = "/work/detail/bonus/list.action";
    /**
     * 详情-操作记录
     */
    public static final String ODP_OPERATOR = "/work/detail/operator.action";
    /**
     * 详情-渠道接口交互记录
     */
    public static final String ODP_CHANNEL_DOCKING = "/work/detail/channelDocking.action";
    /**
     * 详情-优惠分摊明细
     */
    public static final String ODP_DISCOUNT_SHARING = "/work/detail/discountSharing.action";

    /**
     * 详情-用户新单记录
     */
    public static final String ODP_SUB_WORK_LIST_USER_NEW = "/work/detail/subWorkList/user/new.action";

    /**
     * 详情-返修单记录
     */
    public static final String ODP_SUB_WORK_LIST_REWORK = "/work/detail/subWorkList/rework.action";

    /**
     * 详情-退款单记录
     */
    public static final String ODP_SUB_WORK_LIST_REFUND = "/work/detail/subWorkList/refund.action";

    /**
     * 详情-赔偿单记录
     */
    public static final String ODP_SUB_WORK_LIST_COMPENSATE = "/work/detail/subWorkList/compensate.action";

    // endregion

    /**
     * 操作-特殊优惠-总公司承担
     */
    public static final String ODP_HQ_BEAR_DISCOUNT = "/work/discount/hqdiscount.action";
    /**
     * 操作-特殊优惠-子公司承担
     */
    public static final String ODP_SUB_BEAR_DISCOUNT = "/work/discount/subdiscount.action";

    /**
     * 操作-退款人工退款
     */
    public static final String ODP_MANUAL_REFUND = "/work/manual/refund.action";

    /**
     * 修改_服务品类
     */
    public final static String UPDATE_WORK_SERV_CATEG = "/work/update/servCateg.action";



    /**
     * 啄木鸟工单操作 base path
     */
    public final static Map<Integer, String> PERMIT_MODULE_BASE_PATH = initPermitBasePathMap();

    /**
     * 啄木鸟工单操作 code 和 url 对应关系
     */
    public final static Map<Integer, String> BASE_PERMIT_URL = intitPermitUrlMap();

    /**
     * 工单详情 base path
     */
    public final static Map<Integer, String> ORDER_DETAIL_PERMIT_MODULE_BASE_PATH = initDetailPermitBasePathMap();
    public final static Map<Integer, Integer> ORDER_DETAIL_ZMN_PERMIT_MODULE = initDetailZmnModule();

    /**
     * 工单详情权限
     */
    public final static Map<Integer, Set<String>> ORDER_DETAIL_PERMIT = initOrderDetailPermit();


    /**
     * 工单操作基础url
     *
     * @return
     */
    private static Map<Integer, String> initPermitBasePathMap() {
        Map<Integer, String> map = new HashMap<>();
        // 啄木鸟
        map.put(MODULE_ID_ZS, PATH_ZS);
        // 啄木鸟-会员
        map.put(MODULE_ID_ZS_MEMBER, "/zs/member");
        // 啄木鸟-财务
        map.put(MODULE_ID_ZS_BRANCHFINANCE, "/zs/branchfinance");
        // 啄木鸟-总财
        map.put(MODULE_ID_ZS_HQFINANCE, "/zs/hqfinance");
        // 啄木鸟-话务
        map.put(MODULE_ID_ZS_CUSTOMERSERVICE, "/zs/customerservice");
        // 啄木鸟-品控
        map.put(MODULE_ID_ZS_QUALITYCONTROL, "/zs/qualitycontrol");
        // 啄木鸟-评价
        map.put(MODULE_ID_ZS_ORDER_COMMENT, "/zs/ordercomment");

        // 言而有信
        map.put(MODULE_ID_YEYX, PATH_YEYX);
        // 一步维修
        map.put(MODULE_ID_SAAS, PATH_SAAS);
        // 川南环保
        map.put(MODULE_ID_CNHB, PATH_CNHB);
        return map;
    }

    /**
     * 工单详情基础url
     *
     * @return
     */
    private static Map<Integer, String> initDetailPermitBasePathMap() {
        Map<Integer, String> map = new HashMap<>();
        // 啄木鸟
        map.put(MODULE_ID_ZS, PATH_ZS);
        // 言而有信
        map.put(MODULE_ID_YEYX, PATH_YEYX);
        // 一步维修
        map.put(MODULE_ID_SAAS, PATH_SAAS);
        // 川南环保
        map.put(MODULE_ID_CNHB, PATH_CNHB);
        return map;
    }

    /**
     * 工单详情基础url
     *
     * @return
     */
    private static Map<Integer, Integer> initDetailZmnModule() {
        Map<Integer, Integer> map = new HashMap<>();
        // 啄木鸟-会员
        map.put(MODULE_ID_ZS_MEMBER, MODULE_ID_ZS);
        // 啄木鸟-财务
        map.put(MODULE_ID_ZS_BRANCHFINANCE, MODULE_ID_ZS);
        // 啄木鸟-总财
        map.put(MODULE_ID_ZS_HQFINANCE, MODULE_ID_ZS);
        // 啄木鸟-话务
        map.put(MODULE_ID_ZS_CUSTOMERSERVICE, MODULE_ID_ZS);
        // 啄木鸟-品控
        map.put(MODULE_ID_ZS_QUALITYCONTROL, MODULE_ID_ZS);
        // 啄木鸟-评价
        map.put(MODULE_ID_ZS_ORDER_COMMENT, MODULE_ID_ZS);
        return map;
    }

    /**
     * 啄木鸟工单操作 code 和 url 对应关系
     *
     * @return
     */
    private static HashMap<Integer, String> intitPermitUrlMap() {
        HashMap<Integer, String> map = new HashMap<>();

        map.put(OrderConsts.ORDER_OP_TYPE_UPDATE, "/work/update.action"); // 修改 201
        map.put(OrderConsts.ORDER_OP_TYPE_CONFIRM, "/work/confirm.action"); // 确认 2

        map.put(OrderConsts.ORDER_OP_TYPE_ASSIGN, "/work/assign.action"); // 分单 3
        map.put(OrderConsts.ORDER_OP_TYPE_DISTRIBUTE, "/work/distribute.action"); // 派单 4
        map.put(OrderConsts.ORDER_OP_TYPE_DISTRIBUTE_NEW, "/work/new/distribute.action"); // 派单 4
        map.put(OrderConsts.ORDER_OP_TYPE_SERVICE_COMPLETE, "/work/serviceComplete.action"); // 服务完成 28
        map.put(OrderConsts.ORDER_OP_TYPE_COMPLETE, "/work/complete.action"); // 完成 7
        map.put(OrderConsts.ORDER_OP_TYPE_CHECKOUT, "/work/checkout.action"); // 收单 8 - 子公司角色
        map.put(OrderConsts.ORDER_OP_TYPE_ACCOUNT, "/work/account.action"); // 算账 9 - 子公司角色
        map.put(OrderConsts.ORDER_OP_TYPE_REPLY_VISIT, "/work/reply_visit.action"); // 回访 13
        map.put(OrderConsts.ORDER_OP_TYPE_ADMIN_CHECKOUT, "/work/admin_checkout.action"); // 收单 14 - 子公司老总&总部角色
        map.put(OrderConsts.ORDER_OP_TYPE_ADMIN_ACCOUNT, "/work/admin_account.action"); // 算账 15 - 子公司老总&总部角色
        map.put(OrderConsts.ORDER_OP_TYPE_CANCEL, "/work/cancel.action"); // 取消 16
        map.put(OrderConsts.ORDER_OP_TYPE_COPY, "/work/copy.action"); // 复制 101
        map.put(OrderConsts.ORDER_OP_TYPE_REWORK, "/work/rework.action"); // 返修 102
        map.put(OrderConsts.ORDER_OP_TYPE_DETAIL, "/work/detail.action"); // 详情 103
        map.put(OrderConsts.ORDER_OP_TYPE_REMARK, "/work/remark.action"); // 备注 104
        map.put(OrderConsts.ORDER_OP_TYPE_ASSIGN_BACK, "/work/assign/back.action"); // 分单撤回 105
        map.put(OrderConsts.ORDER_OP_TYPE_DISTRIBUTE_BACK, "/work/distribute/back.action"); // 派单撤回 23
        map.put(OrderConsts.ORDER_OP_TYPE_TURN, "/work/turn.action"); // 转单 25
        map.put(OrderConsts.ORDER_OP_TYPE_ORDER_PHOTO, "/work/update_order_photo.action"); // 操作工单照片 26
        map.put(OrderConsts.ORDER_OP_TYPE_SUSPEND, "/work/suspend.action"); // 操作挂起 27
        map.put(OrderConsts.ORDER_OP_TYPE_MULTI_MASTER, "/work/multi_master.action"); // 多工程师 107
        map.put(OrderConsts.ORDER_OP_TYPE_MASTER_SHARING, "/work/mastersharing.action"); // 多工程师 107

        map.put(OrderConsts.ORDER_OP_TYPE_UPDATE_CHANNEL, "/work/update_channel.action"); // 改渠道 202
        map.put(OrderConsts.ORDER_OP_TYPE_UPDATE_APPLIQUE, "/work/update_applique.action"); // 改贴花 203
//        map.put(OrderConsts.ORDER_OP_TYPE_UPDATE_STATUS, "/work/update_status.action"); // 改状态 204
//        map.put(OrderConsts.ORDER_OP_TYPE_UPDATE_PRICE, "/work/update_price.action"); // 改定金 205
        map.put(OrderConsts.ORDER_OP_TYPE_UPDATE_CHANNEL_PREPAY_AMOUNT, "/work/update_channel_prepay_amount.action"); // 改预付款 206
//        map.put(OrderConsts.ORDER_OP_TYPE_UPDATE_CHANNEL_AMOUNT, "/work/update_channel_amount.action"); // 改渠道费 207
        map.put(OrderConsts.ORDER_OP_TYPE_DISCOUNT_LEVEL_ONE, "/work/level_one.action"); // 优惠 六折 209
//        map.put(OrderConsts.ORDER_OP_TYPE_DISCOUNT_LEVEL_TWO, "/work/level_two.action"); // 优惠 七折 210
//        map.put(OrderConsts.ORDER_OP_TYPE_DISCOUNT_LEVEL_THREE, "/work/level_three.action"); // 优惠 九折 211
//        map.put(OrderConsts.ORDER_OP_TYPE_ADMIN_UPDATE_CHANNEL_PREPAY_AMOUNT, "/work/admin_update_channel_prepay_amount.action"); // 总部改渠道预收 212
        map.put(OrderConsts.ORDER_OP_TYPE_DISCOUNT_FREE, "/work/discount.action"); // 特殊优惠 214
        map.put(OrderConsts.ORDER_OP_TYPE_SERVICE_ITEM, "/work/service_item.action"); // 改价格 301
        map.put(OrderConsts.ORDER_OP_TYPE_PART, "/work/part.action"); // 核配件 302
        map.put(OrderConsts.ORDER_OP_TYPE_WARRANTY, "/work/warranty.action"); // 保修信息 303
        map.put(OrderConsts.ORDER_OP_TYPE_PART_REIMBURSE, "/work/part_reimburse.action"); // 配件报销 401
        map.put(OrderConsts.ORDER_OP_TYPE_INVOICE, "/work/invoice.action"); // 开发票 402
        map.put(OrderConsts.ORDER_OP_TYPE_INVOICE_REMIND, "/work/invoiceRemind.action"); // 推送开票 404
        map.put(OrderConsts.ORDER_OP_TYPE_INVOICE_FEED_BACK, "/work/invoiceFeedBack.action"); // 发票反馈 406
        map.put(OrderConsts.ORDER_OP_TYPE_REFUND, "/work/refund.action"); // 退款单 403
//        map.put(OrderConsts.ORDER_OP_TYPE_TRACK, "/work/track.action"); // 跟单 501
        map.put(OrderConsts.ORDER_OP_TYPE_TRACK_NEW, "/work/newtrack.action"); // 跟单（新） 505
        map.put(OrderConsts.ORDER_OP_TYPE_COMPLAINT, "/work/complaint.action"); // 投诉 502
        map.put(OrderConsts.ORDER_OP_TYPE_ABNORMAL, "/work/abnormal.action"); // 服务异常 503
        map.put(OrderConsts.ORDER_OP_TYPE_COMMENT_REMARK, "/work/order_comment/remark.action"); // 评价备注 504
        map.put(OrderConsts.ORDER_OP_TYPE_MEM_PLAT_REVIEW, "/work/mem_plat_review.action"); // 会员单后台审核 702
        map.put(OrderConsts.ORDER_OP_TYPE_SIGN_IN, "/work/sign/in.action"); // 签到 708
        map.put(OrderConsts.ORDER_OP_TYPE_CALL_LOG, "/work/callRecord.action"); // 通话记录 709
        map.put(OrderConsts.ORDER_OP_TYPE_UPDATE_ADDRESS, "/work/update_address.action"); // 修改地址 710
        map.put(OrderConsts.ORDER_OP_TYPE_MODIFY_DUTY_TIME, "/work/update_dutytime.action"); // 修改预约时间 711
        map.put(OrderConsts.ORDER_OP_TYPE_NONSTANDARD, "/work/nonstandard.action");// 非标信息 712
        map.put(OrderConsts.ORDER_OP_TYPE_EXPRESS, "/work/modify/orderpost.action"); // 快递信息 713
        map.put(OrderConsts.ORDER_OP_TYPE_SERVICE_COMPLETE_REVIEW, "/work/serviceCompleteReview.action"); // 服务完成审核 31
        map.put(OrderConsts.ORDER_OP_TYPE_NEW_MACHINE_PART, "/work/modify/newMachinePart.action"); //新机配件信息714
        map.put(OrderConsts.ORDER_OP_TYPE_MANDATORY_DISTRIBUTE, "/work/modify/mandatory/distribute.action"); // 强制派单715
        map.put(OrderConsts.ORDER_OP_TYPE_SPECIAL_ADJUSTMENT, "/work/modify/special_adjustment.action"); // 特殊调整
        map.put(OrderConsts.ORDER_OP_TYPE_REFUND_VOUCHER, "/work/refundVoucher.action"); // 退款凭证 716
        map.put(OrderConsts.ORDER_OP_TYPE_REFUND_VOUCHER_DELETE_IMAGE, "/work/refundVoucher/delete/image.action"); // 退款凭证删除image 717
        map.put(OrderConsts.ORDER_OP_TYPE_REMINDER, "/work/reminder.action"); // 催单 719
        map.put(OrderConsts.ORDER_OP_TYPE_CHANGE_ASSIGNMENT, "/work/modify/change/assignment.action"); // 更改分配 720
        map.put(OrderConsts.ORDER_OP_TYPE_ORDER_TAG, "/work/modify/ordertag.action"); // 标记 720
        map.put(OrderConsts.ORDER_OP_TYPE_COMPENSATE, "/work/compensate.action"); // 赔偿单 721
        map.put(OrderConsts.ORDER_OP_TYPE_COMPENSATE_REVIEW, "/work/compensate/review.action"); // 赔偿单审核 723
        map.put(OrderConsts.ORDER_OP_TYPE_REMIT_VOUCHER, "/work/remit/voucher.action"); // 打款凭证 724
        map.put(OrderConsts.ORDER_OP_TYPE_ORDER_CHECK, "/work/order/check.action"); // 抽查 725
        map.put(OrderConsts.ORDER_OP_TYPE_ORDER_TEMP_XNO, "/work/modify/tempXno.action"); // 临时小号 726
        map.put(OrderConsts.ORDER_OP_TYPE_MULTIPLE_VISIT, "/work/multiple/visit.action"); // 多次上门 111

        return map;
    }

    /**
     * 加载订单详情权限
     * @return
     */
    private static Map<Integer, Set<String>> initOrderDetailPermit(){
        Map<Integer, Set<String>> map = Maps.newHashMap();

        // region zmn 订单权限

        // 敏感信息
        Set<String> zsSet = Sets.newHashSet();
        zsSet.add(OrderPremissionConsts.ODP_USER_ADDRESS);
        zsSet.add(OrderPremissionConsts.ODP_USER_PHONE);
        zsSet.add(OrderPremissionConsts.ODP_CALL_PHONE);
        zsSet.add(OrderPremissionConsts.ODP_ENGINEER_PHONE);
        zsSet.add(OrderPremissionConsts.ODP_ENGINEER_IMCALL);
        zsSet.add(OrderPremissionConsts.ODP_SERVICE_PHONE);
        zsSet.add(OrderPremissionConsts.ODP_VIEW_ALL_LOG);

        // 金额信息
        zsSet.add(OrderPremissionConsts.ODP_COMMISSION_AMOUNT);
        zsSet.add(OrderPremissionConsts.ODP_BILL_AMOUNT);
        zsSet.add(OrderPremissionConsts.ODP_MASTER_REWARD);
        zsSet.add(OrderPremissionConsts.ODP_PRICE_INTERNAL);
        zsSet.add(OrderPremissionConsts.ODP_PRICE_EXTERNAL);
        zsSet.add(OrderPremissionConsts.ODP_PRICE_SELECT);

        zsSet.add(OrderPremissionConsts.ODP_DELIVER_TOTAL_AMOUNT);
        zsSet.add(OrderPremissionConsts.ODP_DELIVER_AMOUNT);

        zsSet.add(OrderPremissionConsts.ODP_IN_PART_COST_TOTAL_AMOUNT);
        zsSet.add(OrderPremissionConsts.ODP_IN_PART_COST_AMOUNT);
        zsSet.add(OrderPremissionConsts.ODP_IN_PART_SALES_TOTAL_AMOUNT);
        zsSet.add(OrderPremissionConsts.ODP_IN_PART_SALES_AMOUNT);
        zsSet.add(OrderPremissionConsts.ODP_IN_PART_PURCHASE_TOTAL_AMOUNT);
        zsSet.add(OrderPremissionConsts.ODP_IN_PART_PURCHASE_AMOUNT);

        zsSet.add(OrderPremissionConsts.ODP_OUT_PART_COST_TOTAL_AMOUNT);
        zsSet.add(OrderPremissionConsts.ODP_OUT_PART_COST_AMOUNT);
        zsSet.add(OrderPremissionConsts.ODP_OUT_PART_SALES_TOTAL_AMOUNT);
        zsSet.add(OrderPremissionConsts.ODP_OUT_PART_SALES_AMOUNT);
        zsSet.add(OrderPremissionConsts.ODP_OUT_PART_PURCHASE_TOTAL_AMOUNT);
        zsSet.add(OrderPremissionConsts.ODP_OUT_PART_PURCHASE_AMOUNT);

        zsSet.add(OrderPremissionConsts.ODP_DMS_MASTER_BONUS);
        zsSet.add(OrderPremissionConsts.ODP_OPERATOR);
        zsSet.add(OrderPremissionConsts.ODP_CHANNEL_DOCKING);
        zsSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_USER_NEW);
        zsSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_REWORK);
        zsSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_REFUND);
        zsSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_COMPENSATE);

        map.put(OrderPremissionConsts.MODULE_ID_ZS, zsSet);
        // endregion

        // region 言而有信 订单权限

        // 敏感信息
        Set<String> ysSet = Sets.newHashSet();
        ysSet.add(OrderPremissionConsts.ODP_USER_ADDRESS);
        ysSet.add(OrderPremissionConsts.ODP_USER_PHONE);
        ysSet.add(OrderPremissionConsts.ODP_SEND_SMS);
        ysSet.add(OrderPremissionConsts.ODP_CALL_PHONE);
        ysSet.add(OrderPremissionConsts.ODP_ENGINEER_IMCALL);
        ysSet.add(OrderPremissionConsts.ODP_ENGINEER_PHONE);
        ysSet.add(OrderPremissionConsts.ODP_SERVICE_PHONE);
        ysSet.add(OrderPremissionConsts.ODP_VIEW_ALL_LOG);

        // 金额信息
        ysSet.add(OrderPremissionConsts.ODP_COMMISSION_AMOUNT);
        ysSet.add(OrderPremissionConsts.ODP_BILL_AMOUNT);
        ysSet.add(OrderPremissionConsts.ODP_MASTER_REWARD);
        ysSet.add(OrderPremissionConsts.ODP_PRICE_INTERNAL);
        ysSet.add(OrderPremissionConsts.ODP_PRICE_EXTERNAL);
        ysSet.add(OrderPremissionConsts.ODP_PRICE_SELECT);

        ysSet.add(OrderPremissionConsts.ODP_DELIVER_TOTAL_AMOUNT);
        ysSet.add(OrderPremissionConsts.ODP_DELIVER_AMOUNT);

        ysSet.add(OrderPremissionConsts.ODP_IN_PART_SALES_TOTAL_AMOUNT);
        ysSet.add(OrderPremissionConsts.ODP_IN_PART_SALES_AMOUNT);
        ysSet.add(OrderPremissionConsts.ODP_IN_PART_COST_TOTAL_AMOUNT);
        ysSet.add(OrderPremissionConsts.ODP_IN_PART_COST_AMOUNT);
        ysSet.add(OrderPremissionConsts.ODP_OUT_PART_COST_TOTAL_AMOUNT);
        ysSet.add(OrderPremissionConsts.ODP_OUT_PART_COST_AMOUNT);
        ysSet.add(OrderPremissionConsts.ODP_OPERATOR);
        ysSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_USER_NEW);
        ysSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_REWORK);
        ysSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_REFUND);
        ysSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_COMPENSATE);

        map.put(OrderPremissionConsts.MODULE_ID_YEYX, ysSet);
        // endregion

        // region 一步维修 订单权限

        // 敏感信息
        Set<String> saasSet = Sets.newHashSet();
        saasSet.add(OrderPremissionConsts.ODP_USER_ADDRESS);
        saasSet.add(OrderPremissionConsts.ODP_USER_PHONE);
        saasSet.add(OrderPremissionConsts.ODP_SEND_SMS);
        saasSet.add(OrderPremissionConsts.ODP_CALL_PHONE);
        saasSet.add(OrderPremissionConsts.ODP_ENGINEER_IMCALL);
        saasSet.add(OrderPremissionConsts.ODP_ENGINEER_PHONE);
        saasSet.add(OrderPremissionConsts.ODP_SERVICE_PHONE);
        saasSet.add(OrderPremissionConsts.ODP_VIEW_ALL_LOG);

        // 金额信息
        saasSet.add(OrderPremissionConsts.ODP_COMMISSION_AMOUNT);
        saasSet.add(OrderPremissionConsts.ODP_BILL_AMOUNT);
        saasSet.add(OrderPremissionConsts.ODP_MASTER_REWARD);
        saasSet.add(OrderPremissionConsts.ODP_PRICE_INTERNAL);
        saasSet.add(OrderPremissionConsts.ODP_PRICE_EXTERNAL);
        saasSet.add(OrderPremissionConsts.ODP_PRICE_SELECT);

        saasSet.add(OrderPremissionConsts.ODP_DELIVER_TOTAL_AMOUNT);
        saasSet.add(OrderPremissionConsts.ODP_DELIVER_AMOUNT);

        saasSet.add(OrderPremissionConsts.ODP_IN_PART_SALES_TOTAL_AMOUNT);
        saasSet.add(OrderPremissionConsts.ODP_IN_PART_SALES_AMOUNT);
        saasSet.add(OrderPremissionConsts.ODP_IN_PART_COST_TOTAL_AMOUNT);
        saasSet.add(OrderPremissionConsts.ODP_IN_PART_COST_AMOUNT);
        saasSet.add(OrderPremissionConsts.ODP_OUT_PART_COST_TOTAL_AMOUNT);
        saasSet.add(OrderPremissionConsts.ODP_OUT_PART_COST_AMOUNT);
        saasSet.add(OrderPremissionConsts.ODP_OPERATOR);
        saasSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_USER_NEW);
        saasSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_REWORK);
        saasSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_REFUND);
        saasSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_COMPENSATE);

        map.put(OrderPremissionConsts.MODULE_ID_SAAS, saasSet);
        // endregion

        // region 川南环保 订单权限

        // 敏感信息
        Set<String> cnhbSet = Sets.newHashSet();
        cnhbSet.add(OrderPremissionConsts.ODP_USER_ADDRESS);
        cnhbSet.add(OrderPremissionConsts.ODP_USER_PHONE);
        cnhbSet.add(OrderPremissionConsts.ODP_SEND_SMS);
        cnhbSet.add(OrderPremissionConsts.ODP_CALL_PHONE);
        cnhbSet.add(OrderPremissionConsts.ODP_ENGINEER_IMCALL);
        cnhbSet.add(OrderPremissionConsts.ODP_ENGINEER_PHONE);
        cnhbSet.add(OrderPremissionConsts.ODP_SERVICE_PHONE);
        cnhbSet.add(OrderPremissionConsts.ODP_VIEW_ALL_LOG);

        // 金额信息
        cnhbSet.add(OrderPremissionConsts.ODP_COMMISSION_AMOUNT);
        cnhbSet.add(OrderPremissionConsts.ODP_BILL_AMOUNT);
        cnhbSet.add(OrderPremissionConsts.ODP_MASTER_REWARD);
        cnhbSet.add(OrderPremissionConsts.ODP_PRICE_INTERNAL);
        cnhbSet.add(OrderPremissionConsts.ODP_PRICE_EXTERNAL);
        cnhbSet.add(OrderPremissionConsts.ODP_PRICE_SELECT);

        cnhbSet.add(OrderPremissionConsts.ODP_DELIVER_TOTAL_AMOUNT);
        cnhbSet.add(OrderPremissionConsts.ODP_DELIVER_AMOUNT);

        cnhbSet.add(OrderPremissionConsts.ODP_IN_PART_SALES_TOTAL_AMOUNT);
        cnhbSet.add(OrderPremissionConsts.ODP_IN_PART_SALES_AMOUNT);
        cnhbSet.add(OrderPremissionConsts.ODP_IN_PART_COST_TOTAL_AMOUNT);
        cnhbSet.add(OrderPremissionConsts.ODP_IN_PART_COST_AMOUNT);
        cnhbSet.add(OrderPremissionConsts.ODP_OUT_PART_COST_TOTAL_AMOUNT);
        cnhbSet.add(OrderPremissionConsts.ODP_OUT_PART_COST_AMOUNT);
        cnhbSet.add(OrderPremissionConsts.ODP_OPERATOR);
        cnhbSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_USER_NEW);
        cnhbSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_REWORK);
        cnhbSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_REFUND);
        cnhbSet.add(OrderPremissionConsts.ODP_SUB_WORK_LIST_COMPENSATE);

        map.put(OrderPremissionConsts.MODULE_ID_CNHB, cnhbSet);
        // endregion

        return map;
    }
    // region 工单菜单权限

    /**
     * 根据平台获取默认 moduleId
     * @param plat
     * @return
     */
    public static Integer getModuleIdByPlat(Integer plat){
        if(plat == null){
            return OrderPremissionConsts.MODULE_ID_ZS;
        }

        switch (plat){
            case GlobalConsts.PLAT_MARK_ZMN:
                return OrderPremissionConsts.MODULE_ID_ZS;
            case GlobalConsts.PLAT_MARK_YEYX:
                return OrderPremissionConsts.MODULE_ID_YEYX;
            case GlobalConsts.PLAT_MARK_CNHB:
                return OrderPremissionConsts.MODULE_ID_CNHB;
            case GlobalConsts.PLAT_MARK_SAAS:
                return OrderPremissionConsts.MODULE_ID_SAAS;
        }

        return OrderPremissionConsts.MODULE_ID_ZS;
    }

    /**
     * 根据平台获取默认 moduleId
     * @param plat
     * @return
     */
    public static String getBasePathByPlat(Integer plat){
        if(plat == null){
            return OrderPremissionConsts.PATH_ZS;
        }

        switch (plat){
            case GlobalConsts.PLAT_MARK_ZMN:
                return OrderPremissionConsts.PATH_ZS;
            case GlobalConsts.PLAT_MARK_YEYX:
                return OrderPremissionConsts.PATH_YEYX;
            case GlobalConsts.PLAT_MARK_CNHB:
                return OrderPremissionConsts.PATH_CNHB;
            case GlobalConsts.PLAT_MARK_SAAS:
                return OrderPremissionConsts.PATH_SAAS;
        }
        return OrderPremissionConsts.PATH_ZS;
    }


    /**
     * 获取详情权限 url
     * @param moduleId
     * @param permit
     * @return
     */
    public static String getDetailPermitUrl(Integer moduleId, String permit) {
        if (Objects.isNull(moduleId)) {
            return null;
        }
        if (StringUtils.isBlank(permit)) {
            return null;
        }

        // 订单详情 moduleId 转换
        Integer newModuleId = OrderPremissionConsts.ORDER_DETAIL_ZMN_PERMIT_MODULE.get(moduleId);
        if (Objects.isNull(newModuleId)) {
            newModuleId = moduleId;
        }

        // 获取路径
        String modulePath = OrderPremissionConsts.ORDER_DETAIL_PERMIT_MODULE_BASE_PATH.get(newModuleId);
        if (Objects.isNull(modulePath)) {
            return null;
        }

        // 获取权限
        Set<String> set = OrderPremissionConsts.ORDER_DETAIL_PERMIT.get(newModuleId);
        if (set == null || set.isEmpty()) {
            return null;
        }

        // 如果url权限范围没有配置，返回有权限
        if (!set.contains(permit)) {
            return null;
        }

        return String.format("%s%s", modulePath, permit);
    }

    /**
     * 获取权限url
     *
     * @param moduleId
     * @param permitCode
     * @return
     */
    public static String getPermitUrlByCode(Integer moduleId, int permitCode) {
        if(moduleId == null){
            return "";
        }
        String baseUrl = BASE_PERMIT_URL.get(permitCode);
        String modulePath = PERMIT_MODULE_BASE_PATH.get(moduleId);
        if (baseUrl != null && modulePath != null) {
            return String.format("%s%s", modulePath, baseUrl);
        }
        return null;
    }

    /**
     * 获取权限url
     * @param moduleId
     * @param permitUrl
     * @return
     */
    public static String getPermitUrlByModuleId(Integer moduleId, String permitUrl) {
        if (moduleId == null) {
            return permitUrl;
        }
        // 获取路径
        String modulePath = OrderPremissionConsts.PERMIT_MODULE_BASE_PATH.get(moduleId);
        if (Objects.isNull(modulePath)) {
            return permitUrl;
        }
        return String.format("%s%s", modulePath, permitUrl);
    }

    // region tab 权限

    /**
     * 精准查询 权限url
     *
     * @param path
     * @return
     */
    public static String getPrecisionPermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/precision/query.action");
    }

    /**
     * 待确认 权限url
     *
     * @param path
     * @return
     */
    public static String getWaitConfirmPermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/wait/confirm.action");
    }

    /**
     * 待转单 权限url
     *
     * @param path
     * @return
     */
    public static String getWaitTurnPermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/wait/turn.action");
    }

    /**
     * 待分单 权限url
     *
     * @param path
     * @return
     */
    public static String getWaitAssignPermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/wait/assign.action");
    }

    /**
     * 待预约 权限url
     *
     * @param path
     * @return
     */
    public static String getWaitDutyTimePermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/wait/duty/time.action");
    }

    /**
     * 待派单 权限url
     *
     * @param path
     * @return
     */
    public static String getWaitDistributePermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/wait/distribute.action");
    }

    /**
     * 待领单 权限url
     *
     * @param path
     * @return
     */
    public static String getWaitTakePermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/wait/take.action");
    }

    /**
     * 待服务审核 权限url
     *
     * @param path
     * @return
     */
    public static String getWaitReviewPermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/wait/review.action");
    }

    /**
     * 待收单 权限url
     *
     * @param path
     * @return
     */
    public static String getWaitCheckoutPermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/wait/checkout.action");
    }

    /**
     * 待退款 权限url
     *
     * @param path
     * @return
     */
    public static String getWaitRefundPermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/wait/refund.action");
    }

    /**
     * 待算账 权限url
     *
     * @param path
     * @return
     */
    public static String getWaitAccountPermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/wait/account.action");
    }

    /**
     * 待报销 权限url
     *
     * @param path
     * @return
     */
    public static String getWaitReimbursePermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/wait/reimburse.action");
    }

    /**
     * 本月开发票 权限url
     *
     * @param path
     * @return
     */
    public static String getWaitCurrentMonthInvoicePermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/current/month/invoice.action");
    }

    /**
     * 待回访 权限url
     *
     * @param path
     * @return
     */
    public static String getWaitVisitPermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/wait/visit.action");
    }

    /**
     * 取消缘由 权限url
     *
     * @param path
     * @return
     */
    public static String getWaitCancelReasonPermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/cancel/reason.action");
    }

    /**
     * 计价器工单 权限url
     *
     * @param path
     * @return
     */
    public static String getQuotationPermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/quotation.action");
    }

    /**
     * 天猫订单 权限url
     *
     * @param path
     * @return
     */
    public static String getTmailOrderPermitUrl(String path) {
        return String.format("%s%s", path, "/work/list/tmail/order.action");
    }


    /**
     * 订单列表-地址权限
     *
     * @param moduleId
     * @return
     */
    public static String getOrderWorkListAddressPermitUrl(Integer moduleId) {
        if (moduleId == null) {
            return "";
        }
        // 获取路径
        String modulePath = OrderPremissionConsts.PERMIT_MODULE_BASE_PATH.get(moduleId);
        if (Objects.isNull(modulePath)) {
            return "";
        }
        return String.format("%s%s", modulePath, "/work/list/address.action");
    }

    /**
     * 订单列表-手机号权限
     *
     * @param moduleId
     * @return
     */
    public static String getOrderWorkListTelPhonePermitUrl(Integer moduleId) {
        if (moduleId == null) {
            return "";
        }
        // 获取路径
        String modulePath = OrderPremissionConsts.PERMIT_MODULE_BASE_PATH.get(moduleId);
        if (Objects.isNull(modulePath)) {
            return "";
        }
        return String.format("%s%s", modulePath, "/work/list/telphone.action");
    }

    /**
     * 订单列表-手机号权限
     *
     * @param moduleId
     * @return
     */
    public static String getOrderWorkUpdateUserPhonePermitUrl(Integer moduleId) {
        if (moduleId == null) {
            return "";
        }
        // 获取路径
        String modulePath = OrderPremissionConsts.PERMIT_MODULE_BASE_PATH.get(moduleId);
        if (Objects.isNull(modulePath)) {
            return "";
        }
        return String.format("%s%s", modulePath, "/work/update/userPhone.action");
    }

    // endregion

    public static void main(String[] args) {
        Integer moduleId = new Integer(550);
        System.out.println(OrderPremissionConsts.getDetailPermitUrl(moduleId, OrderPremissionConsts.ODP_USER_PHONE));
    }
}
